﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Security;

using Bricks.Component.Utils;
using Bricks.Business.Models;
using Bricks.Business.Models.ProjectContract;
using Bricks.Business.Models.Account;
using Bricks.Site.Models;
using Bricks.Business.Data.Repositories.AlterManagement;
using Bricks.Business.Data.Repositories.ProjectContract;
using Bricks.Business.Service;


namespace ChiDao.Business.Service.Impl
{
    [Export(typeof(IContractBillInfoService))]
    internal class ContractBillInfoService : IContractBillInfoService
    {
        [Import]
        protected IContractBillInfoRepository ContractBillInfoRepository { get; set; }

        public List<ContractBillInfoView> GetContractBillInfoList(string contractID)
        {
            IQueryable<ContractBillInfo> contractBillInfos = ContractBillInfoRepository.Entities.Where(c => c.ContractID == contractID);
            List<ContractBillInfoView> contractBillInfoViewList = new List<ContractBillInfoView>();
            foreach (ContractBillInfo contractBillInfo in contractBillInfos)
            {
                contractBillInfoViewList.Add(new ContractBillInfoView()
                {
                    ID = contractBillInfo.ID,
                    ContractID=contractBillInfo.ContractID,
                    PID=contractBillInfo.PID,
                    BillCode = contractBillInfo.BillCode,
                    BillName = contractBillInfo.BillName,
                    NodeType=contractBillInfo.NodeType,
                    BillType = contractBillInfo.BillType,
                    Unit=contractBillInfo.Unit,
                    Price = contractBillInfo.Price,
                    Count = contractBillInfo.Count,
                    Money = contractBillInfo.Money,
                    Remark=contractBillInfo.Remark,
                    //下面是给合同管理添加的
                    AlterPrice = contractBillInfo.AlterPrice,
                    AlterCount = contractBillInfo.AlterCount,
                    AlterMoney = contractBillInfo.AlterMoney,
                    FinishCount = contractBillInfo.FinishCount,
                    FinishMoney = contractBillInfo.FinishMoney,
                    FinishProportion = contractBillInfo.FinishProportion
                });
            }
            return contractBillInfoViewList;
        }
    }
}